﻿using System;
using System.IO;

namespace NDasm.Addin
{
    internal static class Helper
    {
        /// <summary>
        /// Returns absolute path for an absolute or relative paths
        /// </summary>
        /// <param name="path">Absolute or relative path</param>
        /// <param name="basePath">Base path used in case path parameter is a relative path</param>
        /// <returns>Absolute path</returns>
        public static string GetFullPath(string path, string basePath)
        {
            bool isAbsolute = Path.IsPathRooted(path);
            if (isAbsolute)
                return path;
            string saved = Environment.CurrentDirectory;
            Environment.CurrentDirectory = basePath;
            try
            {
                return Path.GetFullPath(path);
            }
            finally
            {
                Environment.CurrentDirectory = saved;
            }
        }
    }
}